home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <sys/types.h>
-
- /* Get rid of implicit declarations */
- unsigned short int htons();
- unsigned short int ntohs();
-
- #define UC(b) (((int) b) & 0xff)
-
- void getport(u_long *p1, u_long *p2, unsigned short int port)
- {
- u_char *p;
- unsigned short int it;
-
- /* We get "PORT ...,16,120" as the 5th and 6th args of port, */
- /* which tells us where we are getting our data, on the client */
- /* transfer port. */
-
- /* p1 is MSB of port, p2 is LSB of port */
- /* given to us by PORT */
-
- it = port;
-
- p = (u_char *) & it;
- *p1 = UC(p[1]), *p2 = UC(p[0]);
- }
-
- unsigned short int getport1(u_long p1, u_long p2)
- {
- unsigned short int it;
-
- /* We get "PORT ...,16,120" as the 5th and 6th args of port, */
- /* which tells us where we are getting our data, on the client */
- /* transfer port. */
-
- /* p1 is MSB of port, p2 is LSB of port */
- /* given to us by PORT */
-
- it = htons((p1 << 8) | p2);
-
- return ntohs(it);
- }
-